package com.hunttown.mes.dao;

import com.hunttown.common.dao.base.BaseDao;
import com.hunttown.common.domain.Query;
import com.hunttown.mes.domain.TransportStaffGrade;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * created by wangjunfu on 2021-02-24 16:00:03
 */
@Repository
public class TransportStaffGradeDao extends BaseDao {
    private static final Logger logger = LoggerFactory.getLogger(TransportStaffGradeDao.class);

    public TransportStaffGrade insert(final TransportStaffGrade transportStaffGrade) {
        insert("TransportStaffGrade.insert", transportStaffGrade);
        return transportStaffGrade;
    }

    public Boolean updateInfoById(final TransportStaffGrade transportStaffGrade) {
        return update("TransportStaffGrade.updateInfoById", transportStaffGrade) > 0;
    }

    public Boolean updateInfoByQuery(final Query query) {
        return update("TransportStaffGrade.updateInfoByQuery", query) > 0;
    }

    public TransportStaffGrade selectById(final Integer id, final Integer entId) {
        Query query = Query.noPage();
        query.put("id", id);
        query.put("entId", entId);
        return queryForObject("TransportStaffGrade.selectById", query);
    }

    public List<TransportStaffGrade> selectByQuery(final Query query) {
        return queryForList("TransportStaffGrade.selectByQuery", query);
    }

    public Long countByQuery(final Query query) {
        return queryForObject("TransportStaffGrade.countByQuery", query);
    }

    public Boolean deleteById(final Integer id, final Integer entId) {
        TransportStaffGrade transportStaffGrade = new TransportStaffGrade();
        transportStaffGrade.setDeleteFlag(1);
        transportStaffGrade.setId(id);
        transportStaffGrade.setEntId(entId);

        return update("TransportStaffGrade.updateInfoById", transportStaffGrade) > 0;
    }

    //物理删除不可恢复，慎用！
    public Boolean deleteByIdForPhysical(final Integer id) {
        Query query = Query.noPage();
        query.put("id", id);
        return delete("TransportStaffGrade.deleteById", query) > 0;
    }
}